#!/usr/bin/env bash

#echo "-------------    maven 编译打包   -------------"
#mvn clean package -Dmaven.test.skip=true

echo "------------- 拷贝 springmvc jar 到远程服务器 -------------"
scp target/springmvc.jar s1:/data/projects/async-demo/springmvc/
echo "------------- 拷贝 Dockerfile 到远程服务器 -------------"
scp Dockerfile s1:/data/projects/async-demo/springmvc/

echo '------------- 登陆远程服务器执行脚本 -------------'
ssh s1 << remotessh
cd /data/projects/async-demo/springmvc/
echo '=============  编译 Docker 镜像  ================='
docker build -t test-springmvc .
echo '=============  删除容器 test-springmvc-0 ============='
docker rm -f test-springmvc-0
echo '=============  启动新容器 ============='
docker run -d --cpuset-cpus=1,2 -m 4G -v /etc/localtime:/etc/localtime:ro -p 51080:8080 -p 51087:51087 --name test-springmvc-0 test-springmvc
remotessh
echo '------------- 执行完毕 ----------------------------------------'
echo '------------- 访问地址:  http://10.32.34.31:51080 -------------'
